package org.qpcr.community.project.web;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hswebframework.web.authorization.annotation.Authorize;
import org.hswebframework.web.authorization.annotation.QueryAction;
import org.hswebframework.web.authorization.annotation.Resource;
import org.hswebframework.web.crud.web.reactive.ReactiveServiceCrudController;
import org.qpcr.community.project.model.entity.DataGroupExperimentalRecordsRelateEntity;
import org.qpcr.community.project.service.DataGroupExperimentalRecordsRelateService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.util.Collection;

@RestController
@RequestMapping({"/project/data-group-experimental-records-relate"})
@Authorize(ignore = true)
@Resource(id = "data-group-experimental-records-relate", name = "数据组别实验记录关联表")
@Slf4j
@Tag(name = "数据组别实验记录关联接口")
@RequiredArgsConstructor
public class DataGroupExperimentalRecordsRelateController  implements
    ReactiveServiceCrudController<DataGroupExperimentalRecordsRelateEntity, String> {

    @Getter
    private final DataGroupExperimentalRecordsRelateService service;


    @PostMapping("batch")
    @QueryAction
    @Authorize(ignore = true)
    public Mono<Integer> saveBatch(@RequestBody Collection<DataGroupExperimentalRecordsRelateEntity> entities) {
        return service.saveBatch(entities);
    }

    @PostMapping("remove")
    @QueryAction
    @Authorize(ignore = true)
    public Mono<Integer> deleteBatch(@RequestBody DataGroupExperimentalRecordsRelateEntity entity) {
        return service.remove(entity);
    }
}
